import { useAuth } from '@/hooks/useAuth';
import { watch } from 'vue';

export function useLoginSwitch(inFn: (user: API.User) => void, outFn?: () => void) {
  const { user, isLogin } = useAuth();

  watch(isLogin, (logged) => (logged ? inFn(user.value) : outFn?.()), { immediate: true });
}
